﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="TemplateList.aspx.cs" Inherits="NetDon.eBoss.Portal.HtmlTool.TemplatenList" %>

<%@ Import Namespace="NetDon.eBoss.Portal" %>
<%@ Register TagPrefix="uc1" TagName="GridPager" Src="~/Controls/GridPager.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var userDialogSize = { width: 900, height: 750 };
        function createCustomer() {

            $dialog('<%=ResolveUrl("~/HtmlTool/TemplateDetailsEdit.aspx") %>?Type=0', userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function modifyCustomer(id, accountId) {
            $dialog('<%=ResolveUrl("~/HtmlTool/TemplateDetailsEdit.aspx") %>?Type=0&Id=' + id + '&AccountId=' + accountId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function deleteDemand(id) {
            $confirm('确定要删除该商品模版吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldCustomerId.ClientID %>'), id);
                    $get('<%=btnDeleteDemand.ClientID %>').click();
                }
            });
        }

        function viewOrder(sender, args) {
            var id = $attr(sender.get_selectedRow(), 'Id');
            var accountId = $attr(sender.get_selectedRow(), 'AccountId');

            $dialog('<%= ResolveUrl("~/HtmlTool/TemplateDetailsEdit.aspx")%>?Type=0&Id=' + id + '&AccountId=' + accountId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }


        function batchModifyOrder(grid) {

            var idArray = GetSelectedIds(grid);

            if (idArray.length <= 0) {
                $alert("请至少选择一笔记录。");
                return;
            }

            $dialog('<%= ResolveUrl("~/HtmlTool/BatchDescriptionEdit.aspx") %>', { width: 780, height: window.top.$common.getClientBounds().height - 200 }, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }

            }, { Ids: idArray.toString() });
        }


        function batchModifyTag(grid) {

            var idArray = GetSelectedIds(grid);

            if (idArray.length <= 0) {
                $alert("请至少选择一笔记录。");
                return;
            }

            $dialog('<%= ResolveUrl("~/HtmlTool/BatchTagEdit.aspx") %>', { width: 780, height: window.top.$common.getClientBounds().height - 200 }, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }

            }, { Ids: idArray.toString() });
        }




        function GetSelectedIds(grid) {
            var idArray = new Array();
            Array.forEach($array($get(grid).getElementsByTagName("tr")), function (elt) {
                if ($attr(elt, "ID")) {
                    $(elt).find("td input:checkbox").each(function (i) {
                        if (this.checked) {
                            idArray.push($attr(elt, "ID"));
                        }
                    });
                }
            });
            return idArray;
        }


        function SelectAll(evtObj) {
            Array.forEach($array($get('<%=gridCustomerInfoList.ClientID %>').getElementsByTagName("input")), function (elt) {

                if (elt.type == "checkbox" && elt.disabled == false) {
                    elt.checked = evtObj.checked;
                }
            });
        }
        function SendSelected(evtObj) {
            var count = 0;
            Array.forEach($array($get('<%=gridCustomerInfoList.ClientID %>').getElementsByTagName("input")), function (elt) {
                if (elt.type == "checkbox" && elt.id != 'checkAll' && elt.checked) {
                    count++;
                }
            });
            if (count == 0) {
                $alert("请至少选择一笔记录.");
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Panel ID="PanelUpload" runat="server" DefaultButton="Button1">
        <span style="display: inline-block; font-weight: bold; height: 22px; line-height: 22px;">
            导入外部文件</span><br />
        <asp:FileUpload ID="FileUpload1" runat="server" />     <asp:Button runat="server" ID="Button1" Text="查询" SkinID="Hidden" OnClick="btnSearch_Click" />
        <asp:Button runat="server" ID="btnImportTemplate" Text="导入模版" OnClick="btnImportTemplate_Click" />
        <br />
        选择账号:<asp:DropDownList ID="ddlAcount" DataSourceID="ObjectDataSourceTemplate" AppendDataBoundItems="True"
            runat="server" DataTextField="Accountname" DataValueField="Id">
        </asp:DropDownList>
        <asp:ObjectDataSource ID="ObjectDataSourceTemplate" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="RetrieveHtmltoolAccounts" TypeName="NetDon.eBoss.Portal.HtmlTool.HtmlToolDataSource">
        </asp:ObjectDataSource>
        <asp:FileUpload ID="FileUpload2" runat="server" />
        <asp:CheckBox runat="server" ID="ckbIsForced" Checked="False" Text="是否强行导入" />
        <asp:Button runat="server" ID="btnImportProduct" Text="导入商品" OnClick="btnImportProduct_Click" />
   
    </asp:Panel>
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td>
                        <NetDon:FormPanel ID="PanelCondition" runat="server" CaptionAlign="NotSet" RepeatColumns="3">
                            <Items>
                                <NetDon:FormItem HeaderText="标签">
                                    <ContentTemplate>
                                        <asp:DropDownList ID="ddlRouteTypeId" DataSourceID="ddsRouteTypeId" AppendDataBoundItems="True"
                                            runat="server" DataTextField="Name" DataValueField="Value" AutoPostBack="True"
                                            OnSelectedIndexChanged="ddlCustomer_SelectedIndexChanged">
                                        </asp:DropDownList>
                                        <NetDon:DictionaryDataSource ID="ddsRouteTypeId" runat="server" CategoryName="标签"
                                            EmptyItemType="Select">
                                        </NetDon:DictionaryDataSource>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="货号">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtItemNo" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="颜色">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtColor" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="商品名称">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtProductName" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="品牌">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtTrademark" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="款式">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtStyle" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="HtmlTool分类" ColumnSpan="2">
                                    <ContentTemplate>
                                        <asp:DropDownList ID="ddlHtmlToolCategory" DataSourceID="ObjectDataSourceCategory"
                                            AppendDataBoundItems="True" runat="server" DataTextField="Category" DataValueField="Id">
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="ObjectDataSourceCategory" runat="server" OldValuesParameterFormatString="original_{0}"
                                            SelectMethod="RetrieveHtmlToolEbayCategory" TypeName="NetDon.eBoss.Portal.HtmlTool.HtmlToolDataSource">
                                        </asp:ObjectDataSource>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                            </Items>
                        </NetDon:FormPanel>
                    </td>
                    <td valign="bottom">
                        <asp:Button runat="server" ID="btnSearch" Text="查询" OnClick="btnSearch_Click" />
                        <asp:Button runat="server" ID="btnBatchModifyDesc" Text="批量修改" />
                        <asp:Button runat="server" ID="btnBatchModifyTag" Text="修改标签" />
                        <asp:Button runat="server" ID="btnBatchDelete" Text="批量删除" OnClick="btnBatchDelete_Click" />
                    </td>
                </tr>
            </table>
            <div style="margin-top: 10px">
                <NetDon:GridView ID="gridCustomerInfoList" runat="server" AutoGenerateColumns="False"
                    OnRowDataBound="gridOrderList_RowDataBound" OnClientRowDblClick="viewOrder" AllowSorting="true">
                    <Columns>
                        <NetDon:TemplateField>
                            <HeaderStyle HorizontalAlign="Center" />
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this)" />
                            </HeaderTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                        <NetDon:TemplateField HeaderText="标签" SortExpression="Tag">
                            <ItemTemplate>
                                <%#GetDictionaryItemName(Eval("Tag"))%>
                            </ItemTemplate>
                        </NetDon:TemplateField>
                        <NetDon:TemplateField HeaderText="预览图">
                            <ItemTemplate>
                                <asp:Image runat="server" ID="imge1" ImageUrl='<%#GetImageUrl(Eval("Picurl1"))%>' />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                        <NetDon:BoundField HeaderText="货号" DataField="Itemno" SortExpression="Itemno">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="颜色" DataField="Color" SortExpression="Color">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="商品名称" DataField="Productname" SortExpression="Productname">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="英文标题" DataField="Englishtitle" SortExpression="Englishtitle">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="80px">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" Style="margin-left: 5px" ToolTip="Edit" runat="server"
                                    CommandName="Edit" SkinID="Modify" ImageAlign="AbsMiddle" CausesValidation="false" />
                                <asp:ImageButton ID="btnDelete" ToolTip="Delete" runat="server" SkinID="Delete" ImageAlign="AbsMiddle"
                                    CausesValidation="false" CommandName="DeleteCustomer" CommandArgument='<%# Eval("Id") %>' />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                    </Columns>
                </NetDon:GridView>
                <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                <asp:HiddenField ID="fieldCustomerId" runat="server" />
                <asp:Button ID="btnDeleteDemand" runat="server" OnClick="btnDeleteDemand_Click" Text="Delete"
                    SkinID="Hidden" />
                <uc1:GridPager ID="PageQueryAdapter1" runat="server" TargetControlID="gridCustomerInfoList"
                    PageSize="20" OnPerformGetCondition="PageQueryAdapter1_PerformGetCondition" OnPerformGetRecordCount="PageQueryAdapter1_PerformGetRecordCount"
                    OnPerformGetPageData="PageQueryAdapter1_PerformGetPageData" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
